/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Rodrigo
 */
@Entity
@Table(name = "evaluacion_curso")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "EvaluacionCurso.findAll", query = "SELECT e FROM EvaluacionCurso e"),
    @NamedQuery(name = "EvaluacionCurso.findById", query = "SELECT e FROM EvaluacionCurso e WHERE e.id = :id"),
    @NamedQuery(name = "EvaluacionCurso.findByPuntaje", query = "SELECT e FROM EvaluacionCurso e WHERE e.puntaje = :puntaje")})
public class EvaluacionCurso implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID")
    private Integer id;
    @Column(name = "PUNTAJE")
    private Short puntaje;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "evaluacionCurso", fetch = FetchType.EAGER)
    private List<ItemEvaluacion> itemEvaluacionList;
    @JoinColumn(name = "USUARIO_EVALUADOR", referencedColumnName = "ID")
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private Usuario usuarioEvaluador;

    public EvaluacionCurso() {
    }

    public EvaluacionCurso(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Short getPuntaje() {
        return puntaje;
    }

    public void setPuntaje(Short puntaje) {
        this.puntaje = puntaje;
    }

    @XmlTransient
    public List<ItemEvaluacion> getItemEvaluacionList() {
        return itemEvaluacionList;
    }

    public void setItemEvaluacionList(List<ItemEvaluacion> itemEvaluacionList) {
        this.itemEvaluacionList = itemEvaluacionList;
    }

    public Usuario getUsuarioEvaluador() {
        return usuarioEvaluador;
    }

    public void setUsuarioEvaluador(Usuario usuarioEvaluador) {
        this.usuarioEvaluador = usuarioEvaluador;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof EvaluacionCurso)) {
            return false;
        }
        EvaluacionCurso other = (EvaluacionCurso) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.EvaluacionCurso[ id=" + id + " ]";
    }
    
}
